package io.renren.hd.controller;


import io.renren.hd.pojo.GenConfig;
import io.renren.hd.service.GenConfigService;
import io.renren.utils.PageUtils;
import io.renren.utils.Query;
import io.renren.utils.R;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.Map;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author LiuZhen
 * @since 2022-04-23
 */
@RestController
@RequestMapping("/config")
public class GenConfigController {

    @Autowired
    private GenConfigService genConfigService;

    @RequestMapping("/list")
    public R list(@RequestParam Map<String, Object> params){
        PageUtils pageUtil = genConfigService.queryList(new Query(params));
        return R.ok().put("page", pageUtil);
    }


    @RequestMapping("/submit")
    public R submit(@RequestBody GenConfig genConfig){
        genConfigService.saveOrUpdate(genConfig);
        return R.ok();
    }


    @RequestMapping("/delete")
    public R delete(@RequestBody List<String> ids){
        genConfigService.removeByIds(ids);
        return R.ok();
    }

}

